home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connectio…eloper Series 2005 March / Dev.CD Mar 05.iso / What's New / Technical Notes and Q&As / ADC Reference Library / qa / qa2001 / downloads / qa1078.hqx / UserAndMachineName / MoreSetup.h < prev   
Encoding:
C/C++ Source or Header  |  2001-09-21  |  5.6 KB  |  160 lines

  1. /*
  2.     File:        MoreSetup.h
  3.  
  4.     Contains:    Sets up conditions etc for MoreIsBetter.
  5.  
  6.     Written by:    Pete Gontier (PCG)
  7.  
  8.     Copyright:    Copyright © 1998 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.  
  20.         <12>     21/9/01    Quinn   Fix CF framework includes workaround.
  21.         <11>     21/9/01    Quinn   Changes for CWPro7 Mach-O build.
  22.         <10>     15/2/01    Quinn   MoreIsBetter now requires UI 3.4 (pre-release) or later.
  23.          <9>      8/2/01    Quinn   Modern versions of MIB require UI 3.3.2 or higher.
  24.          <8>    22/11/00    Quinn   Switch to "MacErrors.h".
  25.          <7>     22/4/99    Quinn   Add a check for the Universal Interfaces version.  MoreIsBetter
  26.                                     requires Universal Interfaces 3.2 or higher (because many of its
  27.                                     component parts do).
  28.          <6>     2/11/99    PCG     add comments because Andy rightfully pointed out my original
  29.                                     attempts sucked; also, remove some excessive TARGET_CARBON
  30.                                     gymnastics
  31.          <5>     1/22/99    PCG     TARGET_CARBON
  32.          <4>    11/11/98    PCG     fix header
  33.          <3>    11/10/98    PCG     separate change histories
  34.          <2>    10/11/98    Quinn   Convert "MorePrefix.h" to "MoreSetup.h".
  35.          <1>    10/11/98    Quinn   Changed name from "MorePrefix.h" to "MoreSetup.h".
  36.  
  37.     Start of "MorePrefix.h" change history (most recent first):
  38.  
  39.          <3>     5/11/98    Quinn   Use MoreAssertQ instead of MoreAssert.
  40.          <2>     7/24/98    PCG        rid of triplet #includes
  41.          <2>     6/23/98    PCG     add copyright disclaimer stuff
  42.          <1>     6/23/98    PCG     initial checkin
  43. */
  44.  
  45. #pragma once
  46.  
  47.     //
  48.     //    We never want to use old names or locations.
  49.     //    Since these settings must be consistent all the way through
  50.     //    a compilation unit, and since we don't want to silently
  51.     //    change them out from under a developer who uses a prefix
  52.     //    file (C/C++ panel of Target Settings), we simply complain
  53.     //    if they are already set in a way we don't like.
  54.     //
  55.  
  56. #ifndef OLDROUTINELOCATIONS
  57.     #define OLDROUTINELOCATIONS 0
  58. #elif OLDROUTINELOCATIONS
  59.     #error OLDROUTINELOCATIONS must be FALSE when compiling MoreIsBetter.
  60. #endif
  61.  
  62. #ifndef OLDROUTINENAMES
  63.     #define OLDROUTINENAMES 0
  64. #elif OLDROUTINENAMES
  65.     #error OLDROUTINENAMES must be FALSE when compiling MoreIsBetter.
  66. #endif
  67.  
  68.     //
  69.     //    We need a master conditional to determine whether to use 
  70.     //    framework notation to reference include files.  Normally 
  71.     //    you would define this in terms of the various TARGET_xxx
  72.     //    variables defined in <ConditionalMacros.h>.  However, you 
  73.     //    can't include <ConditionalMacros.h> until you know 
  74.     //    whether you're supposed to be using framework includes or 
  75.     //    not.  So, we have to pull this conditional out of thin 
  76.     //    air.  Right now the best way to do this is with the 
  77.     //    __MACH__ compiler variable.
  78.     //
  79.  
  80. #if defined(__MACH__)
  81.     #define MORE_FRAMEWORK_INCLUDES 1
  82. #else
  83.     #define MORE_FRAMEWORK_INCLUDES 0
  84. #endif
  85.  
  86.     //
  87.     //    The next statement sets up the various TARGET_xxx 
  88.     //    variables needed later in this file.  In the framework 
  89.     //    include case we just include <Carbon/Carbon.h>, which 
  90.     //    brings everything in, including <ConditionalMacros.h>.
  91.     //    In the non-framework include case we just bring in the 
  92.     //    specific file.
  93.     //
  94.     
  95. #if MORE_FRAMEWORK_INCLUDES
  96.  
  97.     //
  98.     //    This define works around a problem in <CoreFoundation/CFBase.h>
  99.     //    in Mac OS X 10.1.  CF is assuming that the CW Mach-O compiler 
  100.     //    would not use framework includes, which is not the case for the 
  101.     //    CWPro7 compiler.  We only do this for the CW build because 
  102.     //    otherwise the presence of the define prevents Project Builder 
  103.     //    from using Carbon's precompiled header.
  104.     //
  105.     
  106.     #if defined(__MWERKS__)
  107.         #define __CF_USE_FRAMEWORK_INCLUDES__ 1
  108.     #endif
  109.  
  110.     #include <Carbon/Carbon.h>
  111. #else
  112.     #include <ConditionalMacros.h>
  113. #endif
  114.     
  115.     // 
  116.     //    Previouly we would bring in <MacErrors.h> at this point.
  117.     //    However, that's somewhat counter to the idea behind flat 
  118.     //    includes, so I've eliminated it.
  119.     //
  120.  
  121.  
  122.     //
  123.     //    Now that we've included a Mac OS interface file,
  124.     //    we know that the Universal Interfaces environment
  125.     //    is set up.  MoreIsBetter requires Universal Interfaces
  126.     //    3.4 or higher.  Check for it.
  127.     //
  128.  
  129. #if !defined(UNIVERSAL_INTERFACES_VERSION) || UNIVERSAL_INTERFACES_VERSION < 0x0340
  130.     #error MoreIsBetter requires Universal Interfaces 3.4 or higher.
  131. #endif
  132.  
  133.     //
  134.     //    We usually want assertions and other debugging code
  135.     //    turned on, but you can turn it all off if you like
  136.     //    by setting MORE_DEBUG to 0.
  137.     //
  138.  
  139. #ifndef MORE_DEBUG
  140.     #define MORE_DEBUG 1
  141. #endif
  142.  
  143.     //
  144.     //    Our assertion macros compile down to nothing if
  145.     //    MORE_DEBUG is not true. MoreAssert produces a
  146.     //    value indicating whether the assertion succeeded
  147.     //    or failed. MoreAssertQ is Quinn's flavor of
  148.     //    MoreAssert which does not produce a value.
  149.     //
  150.  
  151. #if MORE_DEBUG
  152.     #define MoreAssert(x) \
  153.         ((x) ? true : (DebugStr ("\pMoreAssert failure: " #x), false))
  154.     #define MoreAssertQ(x) \
  155.         do { if (!(x)) DebugStr ("\pMoreAssertQ failure: " #x); } while (false)
  156. #else
  157.     #define MoreAssert(x) (true)
  158.     #define MoreAssertQ(x)
  159. #endif
  160.